const Banner = require('@models/banner');

/**
 * 获取轮播图列表
 * @param {Object} req - 请求对象
 * @param {Object} res - 响应对象
 * @param {Function} next - 下一个中间件
 */
exports.getBanners = async (req, res, next) => {
  try {
    // 只获取状态正常的轮播图
    const banners = await Banner.findAll({
      where: { status: 1 },
      order: [
        ['sort', 'ASC'],
        ['id', 'DESC']
      ]
    });

    res.json({
      code: 200,
      message: '获取成功',
      data: banners
    });
  } catch (err) {
    next(err);
  }
}; 